<style lang="less">
    @import './own-space.less';
</style>

<template>
    <Card>
        <Tabs value="1">
            <TabPane label="个人信息" name="1">
                <Form
                        ref="userForm"
                        :model="userForm"
                        :label-width="100"
                        label-position="right"
                        :rules="inforValidate"
                >
                    <FormItem label="用户姓名：" prop="name">
                        <div style="display:inline-block;width:300px;">
                            <label>{{userForm.name}}</label>
                        </div>
                    </FormItem>
                    <FormItem label="当前岗位：" prop="cellphone" >
                        <div style="display:inline-block;width:300px;">
                            <label>{{userForm.job | jobFilter}}</label>
                        </div>
                    </FormItem>
                    <FormItem label="账户类型：" prop="cellphone" >
                        <div style="display:inline-block;width:300px;">
                            <label>{{userForm.isAdmin | isAdminFilter}}</label>
                        </div>
                    </FormItem>
                    <FormItem label="职能范围：" prop="cellphone" >
                        <div style="display:inline-block;width:300px;">
                            <label>{{userForm.isLogistics}}</label>
                        </div>
                    </FormItem>
                    <FormItem label="登录密码：">
                        <Button type="text" size="small" @click="showEditPassword"><a href="#">修改密码</a></Button>
                    </FormItem>
                    <div>
                        <Button type="text" style="width: 100px;" @click="cancelEditUserInfor">取消</Button>
                        <Button type="primary" style="width: 100px;" :loading="save_loading" @click="saveEdit">保存</Button>
                    </div>
                </Form>
            </TabPane>
            <TabPane label="请假记录" name="2">
                <Button type="info" @click="showLeaveDetails">请假</Button>
                <Button type="success" @click="showOutDetails">外出</Button>
                <Button type="warning" @click="relaxation">调休</Button>
                <iview-table
                        ref="attendanceTable"
                        :baseURL="queryModel.attendance.baseURL"
                        :menuId="dataModel.attendance.menuId"
                        :columns="dataModel.attendance.columns"
                        :order="dataModel.attendance.order"
                        :pageNumber="pageModel.attendance.pageNumber"
                        :pageSize="pageModel.attendance.pageSize"
                        :defaultFilters="queryModel.attendance.defaultFilters"
                        v-on="{events:events,dblclick:dblclick}">
                </iview-table>
            </TabPane>
            <TabPane label="调休记录" name="3">
                <iview-table
                        ref="relaxationTable"
                        :baseURL="queryModel.relaxation.baseURL"
                        :menuId="dataModel.relaxation.menuId"
                        :columns="dataModel.relaxation.columns"
                        :order="dataModel.relaxation.order"
                        :pageNumber="pageModel.relaxation.pageNumber"
                        :pageSize="pageModel.relaxation.pageSize"
                        :defaultFilters="queryModel.relaxation.defaultFilters"
                        v-on="{events:events}">
                </iview-table>
            </TabPane>
            <TabPane label="绑定微信" name="4">
                <Card :bordered="false" :dis-hover="true">
                    <p slot="title" style="height: 33px">
                        <Button type="info" @click="getQRCode">获取二维码</Button>
                    </p>
                    <img v-show="showNoPicture" width="430" height="430" src="@/images/noPicture.png"/>
                    <img v-show="!showNoPicture" width="430" height="430" :src="imgURL"/>
                </Card>
            </TabPane>
            <TabPane label="工单" name="5">
                <Tabs :value="selectPane" @on-click="clickTabs">
                    <TabPane label="创建工单" name="1">
                        <Row>
                            <Col span="8">
                                <Form :model="workOrder" :label-width="100">
                                    <FormItem label="问题描述" prop="workContent" :error="oldPassError">
                                        <Input v-model="workOrder.workContent" type="textarea" :autosize="{minRows: 4,maxRows: 5}" placeholder="请输入内容..."></Input>
                                    </FormItem>
                                    <FormItem label="指派给：" prop="userId" :error="oldPassError">
                                        <Select @on-change="changeUser" v-model="workOrder.processUserId" filterable :label-in-value=true>
                                            <Option v-for="item in users" :value="item.id" :key="item.id">{{ item.username }}</Option>
                                        </Select>
                                    </FormItem>
                                    <FormItem label="要求完成时间：" prop="requireCompleteDate" :error="oldPassError">
                                        <Row>
                                            <Col span="11">
                                                <DatePicker format="yyyy-MM-dd" @on-change="changeDate" transfer="true" type="date" placeholder="请选择日期" style="width: 100%"></DatePicker>
                                            </Col>
                                            <Col span="2" align="center">-</Col>
                                            <Col span="11">
                                                <TimePicker format="HH:mm" @on-change="changeTime" transfer="true" type="time" placeholder="请选择时间" style="width: 100%"></TimePicker>
                                            </Col>
                                        </Row>
                                    </FormItem>
                                </Form>
                                <p align="right">
                                    <Button type="info" size="large" @click="submitWorkOrder">提交工单</Button>
                                </p>
                            </Col>
                        </Row>
                    </TabPane>
                    <TabPane label="待我审核" name="2">
                        <work-list1 ref="list1"></work-list1>
                    </TabPane>
                    <TabPane label="待我处理" name="3">
                        <work-list2 ref="list2"></work-list2>
                    </TabPane>
                </Tabs>
            </TabPane>
        </Tabs>
        <Modal v-model="editPasswordModal" :closable='false' :mask-closable=true :width="500">
            <h3 slot="header" style="color:#2D8CF0">修改密码</h3>
            <Form ref="editPasswordForm" :model="editPasswordForm" :label-width="100" label-position="right" :rules="passwordValidate">
                <FormItem label="原密码" prop="oldPass" :error="oldPassError">
                    <Input v-model="editPasswordForm.oldPass" placeholder="请输入现在使用的密码" ></Input>
                </FormItem>
                <FormItem label="新密码" prop="newPass">
                    <Input v-model="editPasswordForm.newPass" placeholder="请输入新密码，至少6位字符" ></Input>
                </FormItem>
                <FormItem label="确认新密码" prop="rePass">
                    <Input v-model="editPasswordForm.rePass" placeholder="请再次输入新密码" ></Input>
                </FormItem>
            </Form>
            <div slot="footer">
                <Button type="text" @click="cancelEditPass">取消</Button>
                <Button type="primary" :loading="savePassLoading" @click="saveEditPass">保存</Button>
            </div>
        </Modal>
        <Modal v-model="showLeave" @on-ok="submit" ok-text="提交" :closable='false' :mask-closable=true :width="500">
            <h3 slot="header" style="color:#2D8CF0">{{modelTitle}}</h3>
            <Row justify="center" class="code-row-bg">
                <Col span="20" offset="2">
                    <Form :model="attendanceRecord" :label-width="100" label-position="right">
                        <FormItem label="请假类型">
                            <Select v-model="attendanceRecord.type">
                                <Option v-for="item in types" :value="item.value" :key="item.value">{{ item.label }}</Option>
                            </Select>
                        </FormItem>
                        <FormItem label="开始时间">
                            <DatePicker @on-change="changeStartDateTime" v-model="attendanceRecord.startTime" type="datetime" :options="startTime" format="yyyy-MM-dd HH:mm" placeholder="请选择开始时间" style="width: 100%"></DatePicker>
                        </FormItem>
                        <FormItem label="结束时间">
                            <DatePicker @on-change="changeEndDateTime" v-model="attendanceRecord.endTime" type="datetime" :options="endTime" format="yyyy-MM-dd HH:mm" placeholder="请选择结束时间" style="width: 100%"></DatePicker>
                        </FormItem>
                        <FormItem label="请假事由">
                            <Input v-model="attendanceRecord.cause" type="textarea" :autosize="{minRows: 2,maxRows: 5}" placeholder="请填写请假原因..."></Input>
                        </FormItem>
                    </Form>
                </Col>
            </Row>
        </Modal>
        <Modal v-model="showOut" @on-ok="submit" ok-text="提交" :closable='false' :mask-closable=true :width="500">
            <h3 slot="header" style="color:#2D8CF0">外出申请</h3>
            <Row justify="center" class="code-row-bg">
                <Col span="20" offset="2">
                    <Form :model="attendanceRecord" :label-width="100" label-position="right">
                        <FormItem label="请假类型">
                            <Tag checkable color="red">外出</Tag>
                        </FormItem>
                        <FormItem label="外出时间">
                            <Row>
                                <Col span="11">
                                    <TimePicker @on-change="changeStartTime" hide-disabled-options :disabled-hours="[0,1,2,3,4,5,6,7,8,9,18,19,20,21,22,23,24]" format="HH:mm" placeholder="开始时间"></TimePicker>
                                </Col>
                                <Col align="center" span="2">-</Col>
                                <Col span="11">
                                    <TimePicker @on-change="changeEndTime" hide-disabled-options :disabled-hours="[0,1,2,3,4,5,6,7,8,9,18,19,20,21,22,23,24]" format="HH:mm" placeholder="结束时间"></TimePicker>
                                </Col>
                            </Row>
                        </FormItem>
                        <FormItem label="外出原因">
                            <Input v-model="attendanceRecord.cause" type="textarea" :autosize="{minRows: 2,maxRows: 5}" placeholder="请填写外出原因..."></Input>
                        </FormItem>
                    </Form>
                </Col>
            </Row>
        </Modal>
        <Modal v-model="showRelaxation" @on-ok="relaxaConfirm" ok-text="提交" :closable='false' :mask-closable=true :width="500">
            <h3 slot="header" style="color:#2D8CF0">调休申请</h3>
            <Row justify="center" class="code-row-bg">
                <Col span="20" offset="2">
                    <Form :model="attendanceRecord" :label-width="100" label-position="right">
                        <FormItem label="开始时间">
                            <DatePicker @on-change="changeStartDateTime" v-model="attendanceRecord.startTime" type="datetime" :options="startTime" format="yyyy-MM-dd HH:mm" placeholder="请选择开始时间" style="width: 100%"></DatePicker>
                        </FormItem>
                        <FormItem label="结束时间">
                            <DatePicker @on-change="changeEndDateTime" v-model="attendanceRecord.endTime" type="datetime" :options="endTime" format="yyyy-MM-dd HH:mm" placeholder="请选择结束时间" style="width: 100%"></DatePicker>
                        </FormItem>
                        <FormItem label="调休原因">
                            <Input v-model="attendanceRecord.reasonsRest" type="textarea" :autosize="{minRows: 2,maxRows: 5}" placeholder="请填写请假原因..."></Input>
                        </FormItem>
                    </Form>
                </Col>
            </Row>
        </Modal>
    </Card>
</template>

<script>
import iviewTable from '@/view/common/table/Table.vue';
import expandRow from './user-center-expand.vue';
import workList1 from '@/views/own-space/list/WorkList1.vue'
import workList2 from '@/views/own-space/list/WorkList2.vue'
export default {
    name: 'ownspace_index',
    components: {
        iviewTable: iviewTable,
        expandRow,
        workList1,
        workList2
    },
    data () {
        const validePhone = (rule, value, callback) => {
            var re = /^1[0-9]{10}$/;
            if (!re.test(value)) {
                callback(new Error('请输入正确格式的手机号'));
            } else {
                callback();
            }
        };
        const valideRePassword = (rule, value, callback) => {
            if (value !== this.editPasswordForm.newPass) {
                callback(new Error('两次输入密码不一致'));
            } else {
                callback();
            }
        };
        return {
            imgURL: '',
            showNoPicture: true,
            users: [],
            selectPane: '',
            modelTitle: '',
            userForm: {
                name: this.$store.state.app.loginUser.username,
                job: this.$store.state.app.loginUser.job
            },
            attendanceRecord: {
                state: '',
                type: '',
                startTimeStr: '',
                endTimeStr: '',
                cause: '',
                status: '',
                reasonsRest: '',
                userId: '',
                userName: ''
            },
            requireCompleteDate: '',
            requireCompleteTime: '',
            workOrder: {
                workContent: '',
                processUserId: '',
                processUserName: '',
                requireCompleteTimeStr: ''
            },
            uid: '', // 登录用户的userId
            securityCode: '', // 验证码
            phoneHasChanged: false, // 是否编辑了手机
            save_loading: false,
            identifyError: '', // 验证码错误
            editPasswordModal: false, // 修改密码模态框显示
            savePassLoading: false,
            oldPassError: '',
            identifyCodeRight: false, // 验证码是否正确
            hasGetIdentifyCode: false, // 是否点了获取验证码
            canGetIdentifyCode: false, // 是否可点获取验证码
            checkIdentifyCodeLoading: false,
            inforValidate: {
                name: [
                    { required: true, message: '请输入姓名', trigger: 'blur' }
                ],
                cellphone: [
                    { required: true, message: '请输入手机号码' },
                    { validator: validePhone }
                ]
            },
            editPasswordForm: {
                oldPass: '',
                newPass: '',
                rePass: ''
            },
            passwordValidate: {
                oldPass: [
                    { required: true, message: '请输入原密码', trigger: 'blur' }
                ],
                newPass: [
                    { required: true, message: '请输入新密码', trigger: 'blur' },
                    { min: 6, message: '请至少输入6个字符', trigger: 'blur' },
                    { max: 32, message: '最多输入32个字符', trigger: 'blur' }
                ],
                rePass: [
                    { required: true, message: '请再次输入新密码', trigger: 'blur' },
                    { validator: valideRePassword, trigger: 'blur' }
                ]
            },
            inputCodeVisible: false, // 显示填写验证码box
            initPhone: '',
            gettingIdentifyCodeBtnContent: '获取验证码', // “获取验证码”按钮的文字
            types: [{
                value: 1,
                label: '休息'
            },{
                value: 2,
                label: '事假'
            },{
                value: 3,
                label: '病假'
            },{
                value: 4,
                label: '年假'
            },{
                value: 5,
                label: '婚假'
            },{
                value: 6,
                label: '产假'
            },{
                value: 7,
                label: '陪产假'
            },{
                value: 8,
                label: '路途假'
            },{
                value: 9,
                label: '其他'
            }],
            showLeave: false,
            showOut: false,
            showRelaxation: false,
            startTime: {
                disabledDate (date) {
                    return date && date.valueOf() < Date.now() - 86400000;
                }
            },
            endTime: {
                disabledDate (date) {
                    return date && date.valueOf() < Date.now() - 86400000;
                }
            },
            // 查询模型
            queryModel: {
                attendance: {
                    baseURL: '/user/attendance',
                    // 默认过滤条件
                    defaultFilters: [
                        {'field': 'record_type', 'value1': 1, 'operate': '=='},// 请假记录
                        {'field': 'user_id', 'value1': this.$store.state.app.loginUser.id, 'operate': '=='}// 只看自己
                    ]
                },
                relaxation: {
                    baseURL: '/user/attendance',
                    // 默认过滤条件
                    defaultFilters: [
                        {'field': 'record_type', 'value1': 2, 'operate': '=='},// 调休记录
                        {'field': 'user_id', 'value1': this.$store.state.app.loginUser.id, 'operate': '=='}// 只看自己
                    ]
                }
            },
            // 分页模型
            pageModel: {
                attendance: {
                    pageNumber: 1,
                    pageSize: 10
                },
                relaxation: {
                    pageNumber: 1,
                    pageSize: 10
                }
            },
            // 数据模型
            dataModel: {
                attendance: {
                    menuId: -1,
                    columns: [
                        {
                            title: '请假类型',
                            key: 'type',
                            render: (h, params) => {
                                let temp = params.row.type
                                if (temp === 0) {
                                    temp = '外出'
                                } else if (temp === 1) {
                                    temp = '休息'
                                } else if (temp === 2) {
                                    temp = '事假'
                                } else if (temp === 3) {
                                    temp = '病假'
                                } else if (temp === 4) {
                                    temp = '年假'
                                } else if (temp === 5) {
                                    temp = '婚假'
                                } else if (temp === 6) {
                                    temp = '产假'
                                } else if (temp === 7) {
                                    temp = '陪产假'
                                } else if (temp === 8) {
                                    temp = '路途假'
                                } else if (temp === 9) {
                                    temp = '其他'
                                }
                                return temp
                            }
                        },{
                            title: '开始时间',
                            key: 'startTime'
                        },{
                            title: '结束时间',
                            key: 'endTime'
                        },{
                            title: '审批状态',
                            key: 'status',
                            render: (h, params) => {
                                let temp = params.row.status
                                if (temp === 0) {
                                    temp = '待审批'
                                } else if (temp === 1) {
                                    temp = '同意'
                                } else if (temp === 2) {
                                    temp = '拒绝'
                                } else if (temp === 3) {
                                    temp = '已调休'
                                }
                                return temp
                            }
                        }
                    ],
                    order: 'creation_time desc'
                },
                relaxation: {
                    menuId: -1,
                    columns: [
                        {
                            type: 'expand',
                            width: 50,
                            render: (h, params) => {
                                return h(expandRow, {
                                    props: {
                                        row: params.row
                                    }
                                })
                            }
                        },
                        {
                            title: '开始时间',
                            key: 'startTime'
                        },{
                            title: '结束时间',
                            key: 'endTime'
                        },{
                            title: '审批状态',
                            key: 'status',
                            render: (h, params) => {
                                let temp = params.row.status
                                if (temp === 0) {
                                    temp = '待审批'
                                } else if (temp === 1) {
                                    temp = '同意'
                                } else if (temp === 2) {
                                    temp = '拒绝'
                                }
                                return temp
                            }
                        }
                    ],
                    order: 'creation_time desc'
                }
            }
        };
    },
    filters: {
        jobFilter (value) {
            let temp = value
            if (value === 1) {
                temp = '医生'
            } else if (value === 2) {
                temp = '护士'
            }
            return temp
        },
        isAdminFilter (value) {
            let temp = value
            return temp
        }
    },
    methods: {
        refreshWorkList1 () {
            this.$refs.list1.refresh()
        },
        refreshWorkList2 () {
            this.$refs.list2.refresh()
        },
        clickTabs (name) {
            if (name === '1') {
                // 初始化数据
                this.$bus.init(this.workOrder)
                // 加载后勤人员
                this.loadWorkUser()
            } else if (name === '2') {
                this.refreshWorkList1()
            } else if (name === '3') {
                this.refreshWorkList2()
            }
            this.selectPane = name
        },
        changeDate (val) {
            this.requireCompleteDate = val
        },
        changeTime (val) {
            this.requireCompleteTime = val
        },
        submitWorkOrder () {
            if (this.requireCompleteDate !== '') {
                this.workOrder.requireCompleteTimeStr = this.requireCompleteDate
            }
            if (this.requireCompleteTime !== '') {
                this.workOrder.requireCompleteTimeStr += ' ' + this.requireCompleteTime + ':00'
            }
            let url = "/user/work/saveOrUpdate"
            this.$ajax.post(url, this.workOrder).then(response => {
                let {code, msg} = response.data
                if (code === 0) {
                    this.$bus.alert('success', '提交成功')
                    // 初始化数据
                    this.$bus.init(this.workOrder)
                    this.refreshWorkList1()
                } else {
                    this.$bus.alert('error', msg)
                }
            })
        },
        changeUser (option) {
            this.workOrder.processUserId = option.value
            this.workOrder.processUserName = option.label
        },
        loadWorkUser () {
            let url = '/user/getWorkUser'
            this.$ajax.get(url).then(response => {
                let {code, data, msg} = response.data
                if (code === 0) {
                    this.users = data
                } else {
                    this.$bus.alert('error', msg)
                }
            })
        },
        // 获取二维码
        getQRCode () {
            this.$app.post('/wx/subscription/qrcode/get', {
                userId: this.$store.state.app.loginUser.id,
                name: this.$store.state.app.loginUser.username
            }).then((response) => {
                let {errno, data, errmsg} = response.data
                if (errno === 0) {
                    this.imgURL = data
                    this.showNoPicture = false
                } else {
                    this.$bus.alert('error', errmsg)
                }
            })
        },
        getIdentifyCode () {
            this.hasGetIdentifyCode = true;
            this.$refs['userForm'].validate((valid) => {
                if (valid) {
                    this.canGetIdentifyCode = true;
                    let timeLast = 60;
                    let timer = setInterval(() => {
                        if (timeLast >= 0) {
                            this.gettingIdentifyCodeBtnContent = timeLast + '秒后重试';
                            timeLast -= 1;
                        } else {
                            clearInterval(timer);
                            this.gettingIdentifyCodeBtnContent = '获取验证码';
                            this.canGetIdentifyCode = false;
                        }
                    }, 1000);
                    this.inputCodeVisible = true;
                    // you can write ajax request here
                }
            });
        },
        showEditPassword () {
            this.editPasswordModal = true;
        },
        cancelEditUserInfor () {
            this.$store.commit('removeTag', 'ownspace_index');
            localStorage.pageOpenedList = JSON.stringify(this.$store.state.app.pageOpenedList);
            let lastPageName = '';
            if (this.$store.state.app.pageOpenedList.length > 1) {
                lastPageName = this.$store.state.app.pageOpenedList[1].name;
            } else {
                lastPageName = this.$store.state.app.pageOpenedList[0].name;
            }
            this.$router.push({
                name: lastPageName
            });
        },
        saveEdit () {
            this.$refs['userForm'].validate((valid) => {
                if (valid) {
                    if (this.phoneHasChanged && this.userForm.cellphone !== this.initPhone) { // 手机号码修改过了而且修改之后的手机号和原来的不一样
                        if (this.hasGetIdentifyCode) { // 判断是否点了获取验证码
                            if (this.identifyCodeRight) { // 判断验证码是否正确
                                this.saveInfoAjax();
                            } else {
                                this.$Message.error('验证码错误，请重新输入');
                            }
                        } else {
                            this.$Message.warning('请先点击获取验证码');
                        }
                    } else {
                        this.saveInfoAjax();
                    }
                }
            });
        },
        cancelEditPass () {
            this.editPasswordModal = false;
        },
        saveEditPass () {
            this.$refs['editPasswordForm'].validate((valid) => {
                if (valid) {
                    this.savePassLoading = true;
                    // you can write ajax request here
                }
            });
        },
        init () {
            this.refreshAttendance()
        },
        refreshAttendance () {
            this.$refs.attendanceTable.refresh()
        },
        cancelInputCodeBox () {
            this.inputCodeVisible = false;
            this.userForm.cellphone = this.initPhone;
        },
        submitCode () {
            let vm = this;
            vm.checkIdentifyCodeLoading = true;
            if (this.securityCode.length === 0) {
                this.$Message.error('请填写短信验证码');
            } else {
                setTimeout(() => {
                    this.$Message.success('验证码正确');
                    this.inputCodeVisible = false;
                    this.checkIdentifyCodeLoading = false;
                }, 1000);
            }
        },
        hasChangePhone () {
            this.phoneHasChanged = true;
            this.hasGetIdentifyCode = false;
            this.identifyCodeRight = false;
        },
        saveInfoAjax () {
            this.save_loading = true;
            setTimeout(() => {
                this.$Message.success('保存成功');
                this.save_loading = false;
            }, 1000);
        },
        showLeaveDetails () {
            this.modelTitle = '请假申请'
            this.$bus.init(this.attendanceRecord)
            this.showLeave = true
        },
        showOutDetails () {
            this.modelTitle = '外出申请'
            this.$bus.init(this.attendanceRecord)
            this.attendanceRecord.type = 0 // 外出默认为0
            this.showOut = true
        },
        submit () {
            let url = this.queryModel.attendance.baseURL + '/saveOrUpdate'
            this.$ajax.post(url, this.attendanceRecord).then((response) => {
                let {code, msg} = response.data
                if (code === 0) {
                    this.showLeave = false
                    this.$bus.modal('success', '系统提示', '已提交申请')
                    this.refreshAttendance()
                } else {
                    this.$bus.modal('error', '系统提示', '提交失败')
                }
            })
        },
        events () {

        },
        dblclick (row, index) {
            this.modelTitle = '调休申请'
            if (row.type !== 0) {
                // 请假同意才可以调休
                if (row.status === 1) {
                    this.attendanceRecord = row
                    this.showRelaxation = true
                } else {
                    this.$bus.alert("warning", '不符合条件')
                }
            } else {
                this.$bus.modal("warning", undefined, '外出不允许调休')
            }
        },
        changeStartDateTime (value, date) {
            this.attendanceRecord.startTimeStr = value
        },
        changeEndDateTime (value, date) {
            this.attendanceRecord.endTimeStr = value
        },
        changeStartTime (value) {
            let date = this.getDate() + ' ' + value
            this.attendanceRecord.startTimeStr = date
        },
        changeEndTime (value) {
            let date = this.getDate() + ' ' + value
            this.attendanceRecord.endTimeStr = date
        },
        getDate () {
            let date = new Date()
            let month = (date.getMonth() + 1) < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1)
            return date.getFullYear() + '-' + month + '-' + date.getDate()
        },
        relaxation () {
            this.$bus.modal('warning', "操作提示", "请双击需要调休请假记录")
        },
        relaxaConfirm () {
            let url = this.queryModel.relaxation.baseURL + '/relaxation'
            this.$ajax.post(url, this.attendanceRecord).then((response) => {
                let {code} = response.data
                if (code === 0) {
                    this.$bus.modal('success', '系统提示', "已提交申请")
                    this.$refs.attendanceTable.refresh() // 刷新请假列表
                    this.$refs.relaxationTable.refresh() // 刷新调休列表
                } else {
                    this.$bus.modal('error', '系统提示', "提交失败")
                }
            })
        }
    },
    mounted () {
        this.init();
    }
};
</script>
